const { mongoose, db } = require('../utils/mongoose')

let schema = mongoose.Schema({
    id:{type:String,required:true},
    date:{type:String,required:true},
    start:{type:Date,required:true},
    end:{type:Date,required:false},
    content:{type:String,required:true},
    comments:{type:String,required:false}
})

let Collection = mongoose.model('timeArrows', schema)




//新增
const add=(data)=>{
    let model = new Collection(data)
    return model.save()
        .then(res => res)
        .catch(err => {
            return false;
        })
}
//查询
const find=(payload)=>{
    return Collection.find(payload)
        .then(res=>res)
        .catch(err=>{
            console.log(err);
            return false;
        })
}
//操作
const update=(query,updated)=>{
    return Collection.updateOne(query,updated)
        .then(res=>res)
        .catch(err=>{
            console.log(err);
            return false;
        })
}
module.exports={
    add,
    find,
    update,
}